<?php
namespace app\web\dao;

use xto\data\Sql;
use xto\App;
use xto\Util;
use xto\membership\context\Users;

use xto\data\IDao;

class ImgDao extends IDao{
	public function __construct() {
		parent::__construct('web_imgs','mgid'); 
	} 

	public function create($id,$module,$img,$url='',$remark=''){
		$save=[
			'id'=>$id,
			'module'=>$module,
			'img'=>$img,
			'remark'=>$remark,
			'url'=>$url,
			'appid'=>$this->app->appid
		];

		$map['id']=$id;
		$map['module']=$module;

		$id=$this->field($map,'mgid');

		if($id>0){
			$info=array_merge($this->find($id),$save);
			$this->update($info);
		}else{
			$this->save($save);
		}
		return true;
	}
}